/**
 * @class PersonVisuals
 * @extends AbstractPersonVisuals
 * @constructor
 * @param {Person} node 
 * @param {Number} x 
 * @param {Number} y 
 */
var oldProbandArrow = null;
var oldGrapShapStroke = null;
var PersonVisuals = Class.create(AbstractPersonVisuals, {
	initialize: function($super, node, x, y) {
		$super(node, x, y);
		this._nameLabel = null;
		this._stillBirthLabel = null;
		this._ageLabel = null;
		this._externalIDLabel = null;
		this._probabilityLabel = null;
		this._commentsLabel = null;
		this._evaluatedInfoLabel = null;
		this._cancerNameLabel = null;
		this._cancerNameLabel2 = null;
		this._cancerNameLabel3 = null;
		this._cancerNameLabel4 = null;
		this._cancerNameLabel5 = null;
		this.isQuadrantFirst = false;
		this.isQuadrantSecond = false;
		this.isQuadrantThird = false;
		this.isQuadrantFour = false;
		this._childlessStatusLabel = null;
		this._deceasedStatusLabel = null;
		this._disorderShapes = null;
		this._colors = null;
		this._deadShape = null;
		this._unbornShape = null;
		this._childlessShape = null;
		this._isSelected = false;
		this._carrierGraphic = null;
		this._evalLabel = null;
	},
	//更新先证者信息
	upDateProband:function(){	
		var currentId = this.getNode().getID();	
		var currentProbandId = editor.getGraph().getProbandId();
		if(currentId!=currentProbandId){
			//取消原来先证者信息
			var nodeMap = editor.getView().getNodeMap();
			for(key in nodeMap){
				if(key != currentId){
					nodeMap[key]._precursor = 0;
				}		
			}
			for (var nodeID in nodeMap) {
				var node = editor.getView().getNode(nodeID);
				var allProperties = node.getProperties();
				editor.getGraph().setProperties( nodeID, allProperties );
			}
			editor.getGraph().setProbandId(currentId);
			//删除之前先证者
			if(oldProbandArrow){
				oldProbandArrow.pop();
				oldProbandArrow[oldProbandArrow.length].remove();
			}
			if(oldGrapShapStroke){
				oldGrapShapStroke.attr("stroke-width",4);
			}
			//绘制当前先证者
			this._genderGraphics.push(this.generateProbandArrow());
			//this.getGenderShape().transform(["...s", 1.08]);
			//this.getGenderShape().attr("stroke-width", 5.5);
			oldGrapShapStroke = this.getGenderShape();
			oldProbandArrow = this._genderGraphics;

			var changeSet = editor.getGraph().improvePosition();
			editor.getView().applyChanges(changeSet, true);
			// var event = null;
			// document.fire("pedigree:updateProband", event);
		}
	},
	generateHoverbox: function(x, y) {
		if(editor.isReadOnlyMode()) {
			return new ReadOnlyHoverbox(this.getNode(), x, y, this.getGenderGraphics());
		} else {
			return new PersonHoverbox(this.getNode(), x, y, this.getGenderGraphics());
		}
	},

	/**
	 *
	 * @method setGenderGraphics
	 */
	setGenderGraphics: function($super) {
		if(this.getNode().getLifeStatus() == 'aborted' || this.getNode().getLifeStatus() == 'miscarriage') {
			this._genderGraphics && this._genderGraphics.remove();
			var radius = PedigreeEditor.attributes.radius;
			if(this.getNode().isPersonGroup())
				radius *= PedigreeEditor.attributes.groupNodesScale / 2;
			this._shapeRadius = radius;
			//var side = radius * Math.sqrt(3.5),
			var side = radius * Math.sqrt(3.5), //chen.yuguo 改流产和终止任免大小
				height = side / Math.sqrt(2) / 1.5,
				x = this.getX() - height,
				y = this.getY();
			var shape = editor.getPaper().path(["M", x, y, 'l', height, -height, 'l', height, height, "z"]);
			shape.attr(PedigreeEditor.attributes.nodeShape);
			this._genderShape = shape;
			shape = editor.getPaper().set(shape.glow({
				width: 5,
				fill: true,
				opacity: 1
			}), shape);
			if(this.getNode().isProband()) {
				this._genderGraphics.push(this.generateProbandArrow());
				shape.transform(["...s", 1.07]);
				shape.attr("stroke-width", 5);
				oldGrapShapStroke = shape;
				oldProbandArrow = this._genderGraphics;
			}
			if(this.getNode().getGender() == 'U') {
				this._genderGraphics = shape;
			} else {
				x = this.getX();
				y = this.getY() + radius / 1.4;
				var text = (this.getNode().getGender() == 'M') ? " " : " ";
				var genderLabel = editor.getPaper().text(x, y, text).attr(PedigreeEditor.attributes.label);
				this._genderGraphics = editor.getPaper().set(shape, genderLabel);
			}
		} else {
			$super();
		}
		if(this.getNode().isProband()) {
			this._genderGraphics.push(this.generateProbandArrow());
			this.getGenderShape().transform(["...s", 1.08]);
			this.getGenderShape().attr("stroke-width", 5.5);
			oldGrapShapStroke = this.getGenderShape();
			oldProbandArrow = this._genderGraphics;
		}
		if(!editor.isUnsupportedBrowser() && this.getHoverBox()) {
			this._genderGraphics.flatten().insertBefore(this.getFrontElements().flatten());
		}
		this.updateDisorderShapes();
		this.updateCarrierGraphic();
		this.updateEvaluationLabel();
	},
	generateProbandArrow: function() {
		var icon = editor.getPaper().path(editor.getView().__probandArrowPath).attr({
			fill: "#595959",
			stroke: "none",
			opacity: 1,
			id:"proBand"
		});
		var x = this.getX() - this._shapeRadius - 26;
		var y = this.getY() + this._shapeRadius - 12;
		if(this.getNode().getGender() == 'F') {
			x += 5;
			y -= 5;
		}
		//icon.transform(["t", x, y])
		icon.transform(['t',x-15,y+10,'s',2,2]);//chen.yuguo,改先证这箭头
		//alert(x+'--'+y)
		return icon;
	},

	/**
	 *
	 * @method getBackElements
	 * @return {Raphael.st}
	 */
	getBackElements: function() {
		return this.getHoverBox().getBackElements().concat(editor.getPaper().set(this.getChildlessStatusLabel(), this.getChildlessShape()));
	},

	/**
	 *
	 * @method getFrontElements
	 * @return {Raphael.st}
	 */
	getFrontElements: function() {
		return this.getHoverBox().getFrontElements();
	},

	/**
	 *
	 * @method updateExternalIDLabel
	 */
	updateExternalIDLabel: function() {
		this._externalIDLabel && this._externalIDLabel.remove();

		if(this.getNode().getExternalID()) {
			var text = '[' + this.getNode().getExternalID() + "]";
			this._externalIDLabel = editor.getPaper().text(this.getX(), this.getY() + PedigreeEditor.attributes.radius, text).attr(PedigreeEditor.attributes.externalIDLabels);
		} else {
			this._externalIDLabel = null;
		}
		this.drawLabels();
	},

	/**
	 *
	 * @method getExternalIDLabel
	 * @return {Raphael.el}
	 */
	getExternalIDLabel: function() {
		return this._externalIDLabel;
	},

	/**
	 *
	 * @method updateNameLabel
	 */
	updateNameLabel: function() {
		this._nameLabel && this._nameLabel.remove();
		var text = "";
		this.getNode().getFirstName() && (text = this.getNode().getFirstName());

		if(this.getNode().getLastName()) {
			text += ' ' + this.getNode().getLastName();
			this.getNode().getLastNameAtBirth() && (text += ' (' + this.getNode().getLastNameAtBirth() + ')');
		} else
			this.getNode().getLastNameAtBirth() && (text += ' ' + this.getNode().getLastNameAtBirth());
		//如果 个体当前处于怀孕、流产、死胎或终止妊娠状态
		var lifeStatus=this.getNode().getLifeStatus();
		if(lifeStatus && (lifeStatus == "unborn" || lifeStatus=="miscarriage" || lifeStatus=="stillborn" || lifeStatus=="aborted")){
			if(this.getNode().getGestationAge()){
				text+=' '+this.getNode().getGestationAge()+"周"
			}
		}else{
			//添加死亡年龄
			if(this.getNode().getDeathAge()){
				text+=" (d.)"+this.getNode().getDeathAge()+"岁";
			}else{
				//添加当前年龄
				if(this.getNode().getCurentAge()){
					text+=' '+this.getNode().getCurentAge()+"(岁)"
				}
			}
		}	
		this._nameLabel && this._nameLabel.remove();
		if(text.strip() != '') {
			this._nameLabel = editor.getPaper().text(this.getX(), this.getY() + PedigreeEditor.attributes.radius, text).attr(PedigreeEditor.attributes.nameLabels);
		} else {
			this._nameLabel = null;
		}
		//判断癌症
		nametotal = 0;
		var count = 0;
		if (this.getNode.getFirstName!='') {
			nametotal += 1;
		}
		this.getCancerNameLabel() && this.getCancerNameLabel().remove();
		this.getCancerNameLabel2() && this.getCancerNameLabel2().remove();
		this.getCancerNameLabel3() && this.getCancerNameLabel3().remove();
        this.getCancerNameLabel4() && this.getCancerNameLabel4().remove();
        this.getCancerNameLabel5() && this.getCancerNameLabel5().remove();
		if(this.getNode().getHighRelativeCancerName() != "" || this.getNode().getUrogenitalTumorName() != "" || this.getNode().getGastrointestinalTumorName() != "" || this.getNode().getOtherTumorName() != "" || this.getNode().getRareTumorName() != "") {
			var person = this.getNode();
			var tmp_cancer=person.getCancer();
            ageType=person.getCancerAgeType();
            age=person.getCancerAgeNum();
            var lastCancer='';
            var text1 = '';
            var text2 = '';
            var text3 = '';
            var text4 = '';
            var text5 = '';
            //chen.yuguo 显示多个癌症
            if(tmp_cancer.length){
            	//判断是不是有姓名，有则取到前4个，无则取前5个
            	if(this.getNode().getFirstName()){
            		//前四个
            		if(tmp_cancer.length>=4){
            			count = 4;
            		}else{
            			count = tmp_cancer.length;
            		}
            	}else{
            		//前5个
            		if(tmp_cancer.length>=5){
            			count = 5
            		}else{
            			count = tmp_cancer.length;
            		}
            	}
            	for(var i=0;i<count;i++){
            		var text = tmp_cancer[i].name;
            		ageType=tmp_cancer[i].ageType;
                    age=tmp_cancer[i].age;
                    if(ageType == "estimatedage") {
						cancerAgeTypeAbb = "(A)"
					} else if(ageType == "exactage") {
						cancerAgeTypeAbb = "(E)"
					} else if(ageType == "none") {
						cancerAgeTypeAbb = "(U)"
					}
					else
		                cancerAgeTypeAbb = "";
		            
		            if (age){
	                    text += age + "岁"+cancerAgeTypeAbb;
		            }
	                else if(ageType=="none"){
	                    text +=cancerAgeTypeAbb;
	                }
	                if(i==0){
			        	text1 = text;
			        }
			        if(i==1){
			        	text2 = text;
			        }
			        if(i==2){
			        	text3 = text;
			        }
			        if(i==3){
			        	text4 = text;
			        }
			        if(i==4){
			        	text5 = text;
			        }
			    }
			    if(text1){
			          	this._cancerNameLabel = editor.getPaper().text(this.getX(), this.getY(), text1).attr(PedigreeEditor.attributes.label);
                        this._cancerNameLabel.alignTop = true;
				}
				if(text2){
				          	this._cancerNameLabel2 = editor.getPaper().text(this.getX(), this.getY(), text2).attr(PedigreeEditor.attributes.label);
	                        this._cancerNameLabel2.alignTop = true;
				}
				if(text3){
				          	this._cancerNameLabel3 = editor.getPaper().text(this.getX(), this.getY(), text3).attr(PedigreeEditor.attributes.label);
	                        this._cancerNameLabel3.alignTop = true;
				}
				if(text4){
				          	this._cancerNameLabel4 = editor.getPaper().text(this.getX(), this.getY(), text4).attr(PedigreeEditor.attributes.label);
	                        this._cancerNameLabel4.alignTop = true;
				}
				if(text5){
				          	this._cancerNameLabel5 = editor.getPaper().text(this.getX(), this.getY(), text5).attr(PedigreeEditor.attributes.label);
	                        this._cancerNameLabel5.alignTop = true;
				}
				if(this.getNode().getFirstName()!=''){
			     	count+=1;
			     }
			     if(count>=5){
					//删除备注和评估
					this.getCommentsLabel() && this.getCommentsLabel().remove();
					this.getEvaluatedInfoLabel() && this.getEvaluatedInfoLabel().remove();
			     }
				if(count<=3){
					//备注
					this.getCommentsLabel() && this.getCommentsLabel().remove();
					if(this.getNode().getComments() != "") {
						var text = this.getNode().getComments(); //.replace(/\n/g, '<br />');
						this._commentsLabel = editor.getPaper().text(this.getX(), this.getY(), text).attr(PedigreeEditor.attributes.commentLabel);
						this._commentsLabel.alignTop = true;
					} else {
						this._commentsLabel = null;
					}
					//评估
					this.getEvaluatedInfoLabel() && this.getEvaluatedInfoLabel().remove();
					if(this.getNode().getEvaluatedInfo() != "") {
						var text = this.getNode().getEvaluatedInfo(); //.replace(/\n/g, '<br />');
						this._evaluatedInfoLabel = editor.getPaper().text(this.getX(), this.getY(), text).attr(PedigreeEditor.attributes.evaluatedInfoLabel);
						this._evaluatedInfoLabel.alignTop = true;
					} else {
						this._evaluatedInfoLabel = null;
		            }
				}
				if(count==4){
					//备注
					if(this.getNode().getComments() != "") {
						this.getCommentsLabel() && this.getCommentsLabel().remove();
						this.getEvaluatedInfoLabel() && this.getEvaluatedInfoLabel().remove();
						if(this.getNode().getComments() != "") {
							var text = this.getNode().getComments(); //.replace(/\n/g, '<br />');
							this._commentsLabel = editor.getPaper().text(this.getX(), this.getY(), text).attr(PedigreeEditor.attributes.commentLabel);
							this._commentsLabel.alignTop = true;
						} else {
							this._commentsLabel = null;
						}
					} else{
						//评估
						this.getEvaluatedInfoLabel() && this.getEvaluatedInfoLabel().remove();
						if(this.getNode().getEvaluatedInfo() != "") {
							var text = this.getNode().getEvaluatedInfo(); //.replace(/\n/g, '<br />');
							this._evaluatedInfoLabel = editor.getPaper().text(this.getX(), this.getY(), text).attr(PedigreeEditor.attributes.evaluatedInfoLabel);
							this._evaluatedInfoLabel.alignTop = true;
						} else {
							this._evaluatedInfoLabel = null;
			            }
					}
					
				}
            	
			        
            }
		} else {
			this._cancerNameLabel = "未患癌";
		}
		this.drawLabels();
	},

	/**
	 *
	 * @method getNameLabel
	 * @return {Raphael.el}
	 */
	getNameLabel: function() {
		return this._nameLabel;
	},
	updateProbabilityLabel: function() {
		/*this._probabilityLabel && this._probabilityLabel.remove();
		if(this.getNode().getProbability()) {
			var text='概率：' + this.getNode().getProbability();
			this._probabilityLabel = editor.getPaper().text(this.getX(), this.getY() + PedigreeEditor.attributes.radius, text).attr(PedigreeEditor.attributes.probabilityLabels);
		} else {
			this._probabilityLabel = null;
		}
		this.drawLabels();*/
	},
	getProbabilityLabel: function() {
		return this._probabilityLabel;
	},
	getCancerShapes: function() {
		return this._cancerShapes;
	},
	_isQuadrantFirst: function(firstCancerName) {
		return(firstCancerName == 'highcancer_jzxa' || firstCancerName == 'cancertype4' || firstCancerName == 'cancertype5')
	},
	_isQuadrantSecond: function(secondCancerName) {
		return(secondCancerName == 'highcancer_rxa')
	},
	_isQuadrantThird: function(thirdCancerName) {
		return(thirdCancerName == 'highcancer_lca' || thirdCancerName == 'highcancer_zgnma' ||
			thirdCancerName == 'highcancer_qlxa' || thirdCancerName == 'highcancer_sa' || thirdCancerName == 'cancertype2')
	},
	_isQuadrantFour: function(fourCancerName) {
		return(fourCancerName == 'highcancer_jzca' || fourCancerName == 'highcancer_wa' ||
			fourCancerName == 'highcancer_yxa' || fourCancerName == 'cancertype3')
	},
	updateCancerShapes: function() {
		this._disorderShapes && this._disorderShapes.remove();
		var quadrant_first = ["#3399CC", "#fff", "#fff", "#fff"];
		var quadrant_second = ["#fff", "#FF99CC", "#fff", "#fff"];
		var quadrant_third = ["#fff", "#fff", "#FFCC66", "#fff"];
		var quadrant_four = ["#fff", "#fff", "#fff", "#99CC33"];
		var currentCancerName = this.getNode().getHighRelativeCancerName();
		var currentCancerType = this.getNode().getCancerTypes();
		if(this._isQuadrantFirst(currentCancerType) || this._isQuadrantFirst(currentCancerName)) {
			var isQuadrantFirst = true;
		} else {
			var isQuadrantFirst = false;
		}

		if(this._isQuadrantSecond(currentCancerType) || this._isQuadrantSecond(currentCancerName)) {
			var isQuadrantSecond = true;
		} else {
			var isQuadrantSecond = false;
		}

		if(this._isQuadrantThird(currentCancerType) || this._isQuadrantThird(currentCancerName)) {
			var isQuadrantThird = true;
		} else {
			var isQuadrantThird = false;
		}

		if(this._isQuadrantFour(currentCancerType) || this._isQuadrantFour(currentCancerName)) {
			var isQuadrantFour = true;
		} else {
			var isQuadrantFour = false;
		}
		var colors = new Array();
		if(isQuadrantFirst) {
			colors[0] = "#3399CC";
		} else {
			colors[0] = "#fff"
		}

		if(isQuadrantSecond) {
			colors[1] = "#FF99CC";
		} else {
			colors[1] = "#fff"
		}

		if(isQuadrantThird) {
			colors[2] = "#FFCC66";
		} else {
			colors[2] = "#fff"
		}
		if(isQuadrantFour) {
			colors[3] = "#99CC33";
		} else {
			colors[3] = "#fff"
		}
		this._colors = colors;
		if(colors.length == 0) return;
		var gradient = function(color, angle) {
			var hsb = Raphael.rgb2hsb(color),
				darker = "#f5f5f5";
			return angle + "-" + color;
		};
		var disorderShapes = editor.getPaper().set();
		var delta, color;

		if(this.getNode().getLifeStatus() == 'aborted' || this.getNode().getLifeStatus() == 'miscarriage') {
			var radius = PedigreeEditor.attributes.radius;
			if(this.getNode().isPersonGroup())
				radius *= PedigreeEditor.attributes.groupNodesScale;
			var side = radius * Math.sqrt(3.5),
				height = side / Math.sqrt(2),
				x1 = this.getX() - height,
				y1 = this.getY();
			delta = (height * 2) / (colors.length);
			for(var k = 0; k < colors.length; k++) {
				var corner = [];
				var x2 = x1 + delta;
				var y2 = this.getY() - (height - Math.abs(x2 - this.getX()));
				if(x1 < this.getX() && x2 >= this.getX()) {
					corner = ["L", this.getX(), this.getY() - height];
				}
				var slice = editor.getPaper().path(["M", x1, y1, corner, "L", x2, y2, 'L', this.getX(), this.getY(), 'z']);
				color = gradient(colors[k], 70);
				disorderShapes.push(slice.attr({
					fill: color,
					'stroke-width': .5,
					stroke: 'none'
				}));
				x1 = x2;
				y1 = y2;
			}
			if(this.getNode().isProband()) {
				disorderShapes.transform(["...s", 1.04, 1.04, this.getX(), this.getY() - this._shapeRadius]);
			}
		} else {
			var disorderAngle = 90;
			delta = (360 / (colors.length)) / 2;
			if(colors.length == 1 && this.getNode().getGender() == 'U')
				delta -= 45;
			var radius = (this._shapeRadius - 0.6);
			if(this.getNode().getGender() == 'U')
				radius *= 1.155;
			for(var i = 0; i < colors.length; i++) {
				var currentCancerName = this.getNode().getHighRelativeCancerName();
				var currentCancerType = this.getNode().getCancerTypes();
				if(this._isQuadrantFirst(currentCancerType) || this._isQuadrantFirst(currentCancerName)) {
					colors[i] = "#3399CC";
				}
				if(this._isQuadrantSecond(currentCancerType) || this._isQuadrantSecond(currentCancerName)) {
					colors[i] = "#FF99CC";
				}
				if(this._isQuadrantThird(currentCancerType) || this._isQuadrantThird(currentCancerName)) {
					colors[i] = "#FFCC66";
				}
				if(this._isQuadrantFour(currentCancerType) || this._isQuadrantFour(currentCancerName)) {
					colors[i] = "#99CC33";
				}
				color = gradient(colors[i], (i * disorderAngle) + delta);
				if(this.getNode().getLifeStatus() == 'affected') {
					color = '#000000'; //=
				} else {
					color = gradient(colors[i], (i * disorderAngle) + delta);
				}
				disorderShapes.push(sector(editor.getPaper(), this.getX(), this.getY(), radius,
					this.getNode().getGender(), i * disorderAngle, (i + 1) * disorderAngle, color));

			}

			(disorderShapes.length < 2) ? disorderShapes.attr('stroke', 'none'): disorderShapes.attr({
				/*chen.yuguo 解决中间有横线，
                  stroke: '#cc3333',
				'stroke-width': .03
				*/
				stroke: 'none',
			});
			if(this.getNode().isProband()) {
				disorderShapes.transform(["...s", 1.04, 1.04, this.getX(), this.getY()]);
			}
		}
		this._disorderShapes = disorderShapes;
		this._disorderShapes.flatten().insertAfter(this.getGenderGraphics().flatten());
	},
	/**
	 *
	 * @method getDisorderShapes
	 * @return {Raphael.st} Set of disorder shapes
	 */
	getDisorderShapes: function() {
		return this._disorderShapes;
	},

	/**
	 *
	 * @method updateDisorderShapes
	 */
	updateDisorderShapes: function() {
		this._disorderShapes && this._disorderShapes.remove();
		var colors = this.getNode().getAllNodeColors();
		if(colors.length == 0) return;
		var gradient = function(color, angle) {
			var hsb = Raphael.rgb2hsb(color),
				darker = Raphael.hsb2rgb(hsb['h'], hsb['s'], hsb['b'] - .25)['hex'];
			return angle + "-" + darker + ":0-" + color + ":100";
		};
		var disorderShapes = editor.getPaper().set();
		var delta, color;
		if(this.getNode().getLifeStatus() == 'aborted' || this.getNode().getLifeStatus() == 'miscarriage') {
			var radius = PedigreeEditor.attributes.radius;
			if(this.getNode().isPersonGroup())
				radius *= PedigreeEditor.attributes.groupNodesScale;

			var side = radius * Math.sqrt(3.5),
				height = side / Math.sqrt(2),
				x1 = this.getX() - height,
				y1 = this.getY();
			delta = (height * 2) / (colors.length);

			for(var k = 0; k < colors.length; k++) {
				var corner = [];
				var x2 = x1 + delta;
				var y2 = this.getY() - (height - Math.abs(x2 - this.getX()));
				if(x1 < this.getX() && x2 >= this.getX()) {
					corner = ["L", this.getX(), this.getY() - height];
				}
				var slice = editor.getPaper().path(["M", x1, y1, corner, "L", x2, y2, 'L', this.getX(), this.getY(), 'z']);
				color = gradient(colors[k], 70);

				disorderShapes.push(slice.attr({
					fill: color,
					'stroke-width': .5,
					stroke: 'none'
				}));
				x1 = x2;
				y1 = y2;
			}
			if(this.getNode().isProband()) {
				disorderShapes.transform(["...s", 1.04, 1.04, this.getX(), this.getY() - this._shapeRadius]);
			}
		} else {
			var disorderAngle = (360 / colors.length).round();
			delta = (360 / (colors.length)) / 2;
			if(colors.length == 1 && this.getNode().getGender() == 'U')
				delta -= 45;
			var radius = (this._shapeRadius - 0.6);
			if(this.getNode().getGender() == 'U')
				radius *= 1.155;
			for(var i = 0; i < colors.length; i++) {
				color = colors[i];
				var startAngle, endAngle;
				if(colors[i] == "#3399CC") {
					startAngle = 0;
					endAngle = 90;
				} else if(colors[i] == "#FF99CC") {
					startAngle = 90;
					endAngle = 180;
				} else if(colors[i] == "#FFCC66") {
					startAngle = 180;
					endAngle = 270;
				} else if(colors[i] == "#99CC33") {
					startAngle = 270;
					endAngle = 360;
				} else if(this.getNode().getLifeStatus() == 'affected') {
					startAngle = 0;
					endAngle = 360;
				} else {
					startAngle = i * disorderAngle;
					endAngle = (i + 1) * disorderAngle;
				}
				disorderShapes.push(sector(editor.getPaper(), this.getX(), this.getY(), radius,
					this.getNode().getGender(), startAngle, endAngle, color));

			}
			(disorderShapes.length < 2) ? disorderShapes.attr('stroke', 'none'): disorderShapes.attr({
				/*chen.yuguo 解决中间有横线，
                  stroke: '#cc3333',
				'stroke-width': .03
				*/
				stroke: 'none',
			});
			if(this.getNode().isProband()) {
				disorderShapes.transform(["...s", 1.04, 1.04, this.getX(), this.getY()]);
			}
		}
		this._disorderShapes = disorderShapes;
		this._disorderShapes.flatten().insertAfter(this.getGenderGraphics().flatten());
	},

	/**
	 *
	 * @method drawDeadShape
	 */
	drawDeadShape: function() {
		var strokeWidth = editor.getWorkspace().getSizeNormalizedToDefaultZoom(2.5);
		var x, y;
		if(this.getNode().getLifeStatus() == 'aborted') {
			var side = PedigreeEditor.attributes.radius * Math.sqrt(3.5);
			var height = side / Math.sqrt(2);
			if(this.getNode().isPersonGroup())
				height *= PedigreeEditor.attributes.groupNodesScale;

			var x = this.getX() - height / 1.5;
			if(this.getNode().isPersonGroup())
				x -= PedigreeEditor.attributes.radius / 4;

			var y = this.getY() + height / 3;
			this._deadShape = editor.getPaper().path(["M", x, y, 'l', height + height / 3, -(height + height / 3), "z"]);
			this._deadShape.attr("stroke-width", strokeWidth);
		} else {
			x = this.getX();
			y = this.getY();
			var coeff = 10.0 / 8.0 * (this.getNode().isPersonGroup() ? PedigreeEditor.attributes.groupNodesScale : 1.0);
			var x1 = x - coeff * PedigreeEditor.attributes.radius,
				y1 = y + coeff * PedigreeEditor.attributes.radius,
				x2 = x + coeff * PedigreeEditor.attributes.radius,
				y2 = y - coeff * PedigreeEditor.attributes.radius;
			this._deadShape = editor.getPaper().path(["M", x1, y1, "L", x2, y2]).attr("stroke-width", strokeWidth);
		}
		if(!editor.isUnsupportedBrowser()) {
			this._deadShape.toFront();
			this._deadShape.node.setAttribute("class", "no-mouse-interaction");
		}
	},

	/**
	 *
	 * @method getDeadShape
	 * @return {Raphael.st}
	 */
	getDeadShape: function() {
		return this._deadShape;
	},

	/**
	 *
	 * @method getAgeLabel
	 * @return {Raphael.el}
	 */
	getAgeLabel: function() {
		return this._ageLabel;
	},

	/**
	 *
	 * @method updateAgeLabel
	 */
	updateAgeLabel: function() {
		var text,
			person = this.getNode();
		if(person.isFetus()) {
			var date = person.getGestationAge();
			text = (date) ? date + "周" : null;
		} else if(person.getLifeStatus() == 'alive') {
			if(person.getBirthDate()) {
				var age = getAge(person.getBirthDate(), null);
				if(age.indexOf("day") != -1) {
					text = age;
				} else if(age.indexOf(" y") == -1) {
					text = "b. " + person.getBirthDate().getFullYear() + " (" + age + ")";
				} else {
					text = "b. " + person.getBirthDate().getFullYear();
				}
			}
		} else {
			if(person.getDeathDate() && person.getBirthDate()) {
				var age = getAge(person.getBirthDate(), person.getDeathDate());
				if(age.indexOf("day") != -1 || age.indexOf("wk") != -1 || age.indexOf("mo") != -1) {
					text = "d. " + person.getDeathDate().getFullYear() + " (" + age + ")";
				} else {
					text = person.getBirthDate().getFullYear() + " – " + person.getDeathDate().getFullYear();
				}
			} else if(person.getDeathDate()) {
				text = "d. " + person.getDeathDate().getFullYear();
			} else if(person.getBirthDate()) {
				text = person.getBirthDate().getFullYear() + " – ?";
			}
		}
		this.getAgeLabel() && this.getAgeLabel().remove();
		this._ageLabel = text ? editor.getPaper().text(this.getX(), this.getY(), text).attr(PedigreeEditor.attributes.label) : null;
		this.drawLabels();
	},

	/**
	 *
	 * @method getUnbornShape
	 * @return {Raphael.el}
	 */
	getUnbornShape: function() {
		return this._unbornShape;
	},

	/**
	 *
	 * @method drawUnbornShape
	 */
	drawUnbornShape: function() {
		this._unbornShape && this._unbornShape.remove();
		if(this.getNode().getLifeStatus() == 'unborn') {
			this._unbornShape = editor.getPaper().text(this.getX(), this.getY(), "P").attr(PedigreeEditor.attributes.unbornShape);
			if(!editor.isUnsupportedBrowser())
				this._unbornShape.insertBefore(this.getHoverBox().getFrontElements());
		} else {
			this._unbornShape = null;
		}
	},

	/**
	 *
	 * @method updateEvaluationLabel
	 */
	updateEvaluationLabel: function() {
		this._evalLabel && this._evalLabel.remove();
		if(this.getNode().getEvaluated()) {
			if(this.getNode().getLifeStatus() == 'aborted' || this.getNode().getLifeStatus() == 'miscarriage') {
				var x = this.getX() + this._shapeRadius * 1.6;
				var y = this.getY() + this._shapeRadius * 0.6;
			} else {
				var mult = 1.1;
				if(this.getNode().getGender() == 'U') mult = 1.3;
				else if(this.getNode().getGender() == 'M') mult = 1.4;
				if(this.getNode().isProband) mult *= 1.1;
				var x = this.getX() + this._shapeRadius * mult - 5;
				var y = this.getY() + this._shapeRadius * mult;
			}
			this._evalLabel = editor.getPaper().text(x, y, "*").attr(PedigreeEditor.attributes.evaluationShape).toBack();
		} else {
			this._evalLabel = null;
		}
	},

	/**
	 *
	 * @method getEvaluationGraphics
	 * @return {Raphael.el}
	 */
	getEvaluationGraphics: function() {
		return this._evalLabel;
	},

	/**
	 *
	 * @method updateCarrierGraphic
	 */
	updateCarrierGraphic: function() {
		this._carrierGraphic && this._carrierGraphic.remove();
		var status = this.getNode().getCarrierStatus();

		if(status != '' && status != 'affected') {
			if(status == 'carrier') {
				if(this.getNode().getLifeStatus() == 'aborted' || this.getNode().getLifeStatus() == 'miscarriage') {
					x = this.getX();
					y = this.getY() - this._radius / 2;
				} else {
					x = this.getX();
					y = this.getY();
				}
				this._carrierGraphic = editor.getPaper().circle(x, y, PedigreeEditor.attributes.carrierDotRadius).attr(PedigreeEditor.attributes.carrierShape);
			} else if(status == 'presymptomatic') {
				if(this.getNode().getLifeStatus() == 'aborted' || this.getNode().getLifeStatus() == 'miscarriage') {
					this._carrierGraphic = null;
					return;
				}
				editor.getPaper().setStart();
				var startX = (this.getX() - PedigreeEditor.attributes.presymptomaticShapeWidth / 2);
				var startY = this.getY() - this._radius;
				editor.getPaper().rect(startX, startY, PedigreeEditor.attributes.presymptomaticShapeWidth, this._radius * 2).attr(PedigreeEditor.attributes.presymptomaticShape);
				if(this.getNode().getGender() == 'U') {
					editor.getPaper().path("M " + startX + " " + startY +
						"L " + (this.getX()) + " " + (this.getY() - this._radius * 1.1) +
						"L " + (startX + PedigreeEditor.attributes.presymptomaticShapeWidth) + " " + (startY) + "Z").attr(PedigreeEditor.attributes.presymptomaticShape);
					var endY = this.getY() + this._radius;
					editor.getPaper().path("M " + startX + " " + endY +
						"L " + (this.getX()) + " " + (this.getY() + this._radius * 1.1) +
						"L " + (startX + PedigreeEditor.attributes.presymptomaticShapeWidth) + " " + endY + "Z").attr(PedigreeEditor.attributes.presymptomaticShape);
				}
				this._carrierGraphic = editor.getPaper().setFinish();
			}
			if(editor.isReadOnlyMode())
				this._carrierGraphic.toFront();
			else
				this._carrierGraphic.insertBefore(this.getHoverBox().getFrontElements());
		} else {
			this._carrierGraphic = null;
		}
	},

	/**
	 *
	 * @method getCarrierGraphics
	 * @return {Raphael.el}
	 */
	getCarrierGraphics: function() {
		return this._carrierGraphic;
	},

	/**
	 *
	 * @method getSBLabel
	 * @return {Raphael.el}
	 */
	getSBLabel: function() {
		return this._stillBirthLabel;
	},

	/**
	 * @method updateSBLabel
	 */
	updateSBLabel: function() {
		this.getSBLabel() && this.getSBLabel().remove();
		if(this.getNode().getLifeStatus() == 'stillborn') {
			this._stillBirthLabel = editor.getPaper().text(this.getX(), this.getY(), "SB").attr(PedigreeEditor.attributes.label);
		} else {
			this._stillBirthLabel = null;
		}
		this.drawLabels();
	},

	/**
	 *
	 * @method getCommentsLabel
	 * @return {Raphael.el}
	 */
	getCommentsLabel: function() {
		return this._commentsLabel;
	},


	/**
	 *
	 * @method updateCommentsLabel
	 */
	updateCommentsLabel: function() {
		this.getCommentsLabel() && this.getCommentsLabel().remove();
		if(this.getNode().getComments() != "") {
			var text = this.getNode().getComments(); //.replace(/\n/g, '<br />');
			this._commentsLabel = editor.getPaper().text(this.getX(), this.getY(), text).attr(PedigreeEditor.attributes.commentLabel);
			this._commentsLabel.alignTop = true;
		} else {
			this._commentsLabel = null;
		}
		//判断癌症
		nametotal = 0;
		var count = 0;
		if (this.getNode.getFirstName) {
			nametotal += 1;
		}
		this.getCancerNameLabel() && this.getCancerNameLabel().remove();
		this.getCancerNameLabel2() && this.getCancerNameLabel2().remove();
		this.getCancerNameLabel3() && this.getCancerNameLabel3().remove();
        this.getCancerNameLabel4() && this.getCancerNameLabel4().remove();
        this.getCancerNameLabel5() && this.getCancerNameLabel5().remove();
		if(this.getNode().getHighRelativeCancerName() != "" || this.getNode().getUrogenitalTumorName() != "" || this.getNode().getGastrointestinalTumorName() != "" || this.getNode().getOtherTumorName() != "" || this.getNode().getRareTumorName() != "") {
			var person = this.getNode();
			var tmp_cancer=person.getCancer();
            ageType=person.getCancerAgeType();
            age=person.getCancerAgeNum();
            var lastCancer='';
            var text1 = '';
            var text2 = '';
            var text3 = '';
            var text4 = '';
            var text5 = '';
            //chen.yuguo 显示多个癌症
            if(tmp_cancer.length){
            	//判断是不是有姓名，有则取到前4个，无则取前5个
            	if(this.getNode().getFirstName()){
            		//前四个
            		if(tmp_cancer.length>=4){
            			count = 4;
            		}else{
            			count = tmp_cancer.length;
            		}
            	}else{
            		//前5个
            		if(tmp_cancer.length>=5){
            			count = 5
            		}else{
            			count = tmp_cancer.length;
            		}
            	}
            	for(var i=0;i<count;i++){
            		var text = tmp_cancer[i].name;
            		ageType=tmp_cancer[i].ageType;
                    age=tmp_cancer[i].age;
                    if(ageType == "estimatedage") {
						cancerAgeTypeAbb = "(A)"
					} else if(ageType == "exactage") {
						cancerAgeTypeAbb = "(E)"
					} else if(ageType == "none") {
						cancerAgeTypeAbb = "(U)"
					}
					else
		                cancerAgeTypeAbb = "";
		            
		            if (age){
	                    text += age + "岁"+cancerAgeTypeAbb;
		            }
	                else if(ageType=="none"){
	                    text +=cancerAgeTypeAbb;
	                }
	                if(i==0){
			        	text1 = text;
			        }
			        if(i==1){
			        	text2 = text;
			        }
			        if(i==2){
			        	text3 = text;
			        }
			        if(i==3){
			        	text4 = text;
			        }
			        if(i==4){
			        	text5 = text;
			        }
			    }
			    if(text1){
			          	this._cancerNameLabel = editor.getPaper().text(this.getX(), this.getY(), text1).attr(PedigreeEditor.attributes.label);
                        this._cancerNameLabel.alignTop = true;
				}
				if(text2){
				          	this._cancerNameLabel2 = editor.getPaper().text(this.getX(), this.getY(), text2).attr(PedigreeEditor.attributes.label);
	                        this._cancerNameLabel2.alignTop = true;
				}
				if(text3){
				          	this._cancerNameLabel3 = editor.getPaper().text(this.getX(), this.getY(), text3).attr(PedigreeEditor.attributes.label);
	                        this._cancerNameLabel3.alignTop = true;
				}
				if(text4){
				          	this._cancerNameLabel4 = editor.getPaper().text(this.getX(), this.getY(), text4).attr(PedigreeEditor.attributes.label);
	                        this._cancerNameLabel4.alignTop = true;
				}
				if(text5){
				          	this._cancerNameLabel5 = editor.getPaper().text(this.getX(), this.getY(), text5).attr(PedigreeEditor.attributes.label);
	                        this._cancerNameLabel5.alignTop = true;
				}
				if(this.getNode().getFirstName()){
			     	count+=1;
			     }
			     if(count>=5){
					//删除备注和评估
					this.getCommentsLabel() && this.getCommentsLabel().remove();
					this.getEvaluatedInfoLabel() && this.getEvaluatedInfoLabel().remove();
			     }
				if(count<=3){
					//备注
					this.getCommentsLabel() && this.getCommentsLabel().remove();
					if(this.getNode().getComments() != "") {
						var text = this.getNode().getComments(); //.replace(/\n/g, '<br />');
						this._commentsLabel = editor.getPaper().text(this.getX(), this.getY(), text).attr(PedigreeEditor.attributes.commentLabel);
						this._commentsLabel.alignTop = true;
					} else {
						this._commentsLabel = null;
					}
					//评估
					this.getEvaluatedInfoLabel() && this.getEvaluatedInfoLabel().remove();
					if(this.getNode().getEvaluatedInfo() != "") {
						var text = this.getNode().getEvaluatedInfo(); //.replace(/\n/g, '<br />');
						this._evaluatedInfoLabel = editor.getPaper().text(this.getX(), this.getY(), text).attr(PedigreeEditor.attributes.evaluatedInfoLabel);
						this._evaluatedInfoLabel.alignTop = true;
					} else {
						this._evaluatedInfoLabel = null;
		            }
				}
				if(count==4){
					//备注
					if(this.getNode().getComments() != "") {
						this.getEvaluatedInfoLabel() && this.getEvaluatedInfoLabel().remove();
					} else{
						//评估
						this.getEvaluatedInfoLabel() && this.getEvaluatedInfoLabel().remove();
						if(this.getNode().getEvaluatedInfo() != "") {
							var text = this.getNode().getEvaluatedInfo(); //.replace(/\n/g, '<br />');
							this._evaluatedInfoLabel = editor.getPaper().text(this.getX(), this.getY(), text).attr(PedigreeEditor.attributes.evaluatedInfoLabel);
							this._evaluatedInfoLabel.alignTop = true;
						} else {
							this._evaluatedInfoLabel = null;
			            }
					}
					
				}
            	
			        
            }
		} else {
			this._cancerNameLabel = "未患癌";
		}
		this.drawLabels();
	},
	/**
	 *
	 * @method getCancerNameLabel
	 * @return {Raphael.el}
	 */
	getCancerNameLabel: function() {
		return this._cancerNameLabel;
	},
    getCancerNameLabel2: function() {
		return this._cancerNameLabel2;
	},
	getCancerNameLabel3: function() {
		return this._cancerNameLabel3;
	},
	getCancerNameLabel4: function() {
		return this._cancerNameLabel4;
	},
	getCancerNameLabel5: function() {
		return this._cancerNameLabel5;
	},
	/** 
	 * @method updateCancerNameLabel
	 */

	updateCancerNameLabel: function() {
		this.getCancerNameLabel() && this.getCancerNameLabel().remove();
		this.getCancerNameLabel2() && this.getCancerNameLabel2().remove();
		this.getCancerNameLabel3() && this.getCancerNameLabel3().remove();
        this.getCancerNameLabel4() && this.getCancerNameLabel4().remove();
        this.getCancerNameLabel5() && this.getCancerNameLabel5().remove();
         var count = 0;
		if(this.getNode().getHighRelativeCancerName() != "" || this.getNode().getUrogenitalTumorName() != "" || this.getNode().getGastrointestinalTumorName() != "" || this.getNode().getOtherTumorName() != "" || this.getNode().getRareTumorName() != "") {
			var person = this.getNode();
			var tmp_cancer=person.getCancer();
            ageType=person.getCancerAgeType();
            age=person.getCancerAgeNum();
            bPart = person.getSiteOfCancerValue();
            var lastCancer='';
            var text1 = '';
            var text2 = '';
            var text3 = '';
            var text4 = '';
            var text5 = '';
            //chen.yuguo 显示多个癌症
            if(tmp_cancer.length){
            	//判断是不是有姓名，有则取到前4个，无则取前5个
            	if(this.getNode().getFirstName()){
            		//前四个
            		if(tmp_cancer.length>=4){
            			count = 4;
            		}else{
            			count = tmp_cancer.length;
            		}
            	}else{
            		//前5个
            		if(tmp_cancer.length>=5){
            			count = 5
            		}else{
            			count = tmp_cancer.length;
            		}
            	}
            	for(var i=0;i<count;i++){
            		var text = tmp_cancer[i].name;
            		ageType=tmp_cancer[i].ageType;
                    age=tmp_cancer[i].age;
                    bPart=tmp_cancer[i].bPart;
                    if(ageType == "estimatedage") {
						cancerAgeTypeAbb = "(A)"
					} else if(ageType == "exactage") {
						cancerAgeTypeAbb = "(E)"
					} else if(ageType == "none") {
						cancerAgeTypeAbb = "(U)"
					}
					else
		                cancerAgeTypeAbb = "";
		            
		            if (age){
	                    text += age + "岁"+cancerAgeTypeAbb;
		            }
	                else if(ageType=="none"){
	                    text +=cancerAgeTypeAbb;
	                }
	                if(bPart){
                        text+=bPart;
					}
	                if(i==0){
			        	text1 = text;
			        }
			        if(i==1){
			        	text2 = text;
			        }
			        if(i==2){
			        	text3 = text;
			        }
			        if(i==3){
			        	text4 = text;
			        }
			        if(i==4){
			        	text5 = text;
			        }
			    }
			    if(text1){
			          	this._cancerNameLabel = editor.getPaper().text(this.getX(), this.getY(), text1).attr(PedigreeEditor.attributes.label);
                        this._cancerNameLabel.alignTop = true;
				}
				if(text2){
				          	this._cancerNameLabel2 = editor.getPaper().text(this.getX(), this.getY(), text2).attr(PedigreeEditor.attributes.label);
	                        this._cancerNameLabel2.alignTop = true;
				}
				if(text3){
				          	this._cancerNameLabel3 = editor.getPaper().text(this.getX(), this.getY(), text3).attr(PedigreeEditor.attributes.label);
	                        this._cancerNameLabel3.alignTop = true;
				}
				if(text4){
				          	this._cancerNameLabel4 = editor.getPaper().text(this.getX(), this.getY(), text4).attr(PedigreeEditor.attributes.label);
	                        this._cancerNameLabel4.alignTop = true;
				}
				if(text5){
				          	this._cancerNameLabel5 = editor.getPaper().text(this.getX(), this.getY(), text5).attr(PedigreeEditor.attributes.label);
	                        this._cancerNameLabel5.alignTop = true;
				}
				if(this.getNode().getFirstName()){
			     	count+=1;
			     }
			     if(count>=5){
					//删除备注和评估
					this.getCommentsLabel() && this.getCommentsLabel().remove();
					this.getEvaluatedInfoLabel() && this.getEvaluatedInfoLabel().remove();
			     }
				if(count==4 &&this.getCommentsLabel()){
					//评估
					this.getEvaluatedInfoLabel() && this.getEvaluatedInfoLabel().remove();
				}
				if(count>=5){
					//删除备注和评估
					this.getCommentsLabel() && this.getCommentsLabel().remove();
					this.getEvaluatedInfoLabel() && this.getEvaluatedInfoLabel().remove();
			     }
				if(count<=3){
					//备注
					this.getCommentsLabel() && this.getCommentsLabel().remove();
					if(this.getNode().getComments() != "") {
						var text = this.getNode().getComments(); //.replace(/\n/g, '<br />');
						this._commentsLabel = editor.getPaper().text(this.getX(), this.getY(), text).attr(PedigreeEditor.attributes.commentLabel);
						this._commentsLabel.alignTop = true;
					} else {
						this._commentsLabel = null;
					}
					//评估
					this.getEvaluatedInfoLabel() && this.getEvaluatedInfoLabel().remove();
					if(this.getNode().getEvaluatedInfo() != "") {
						var text = this.getNode().getEvaluatedInfo(); //.replace(/\n/g, '<br />');
						this._evaluatedInfoLabel = editor.getPaper().text(this.getX(), this.getY(), text).attr(PedigreeEditor.attributes.evaluatedInfoLabel);
						this._evaluatedInfoLabel.alignTop = true;
					} else {
						this._evaluatedInfoLabel = null;
		            }
				}
				if(count==4){
					//备注
					if(this.getNode().getComments() != "") {
						this.getCommentsLabel() && this.getCommentsLabel().remove();
						if(this.getNode().getComments() != "") {
							var text = this.getNode().getComments(); //.replace(/\n/g, '<br />');
							this._commentsLabel = editor.getPaper().text(this.getX(), this.getY(), text).attr(PedigreeEditor.attributes.commentLabel);
							this._commentsLabel.alignTop = true;
						} else {
							this._commentsLabel = null;
						}
						this.getEvaluatedInfoLabel() && this.getEvaluatedInfoLabel().remove();
					} else{
						//评估
						this.getEvaluatedInfoLabel() && this.getEvaluatedInfoLabel().remove();
						if(this.getNode().getEvaluatedInfo() != "") {
							var text = this.getNode().getEvaluatedInfo(); //.replace(/\n/g, '<br />');
							this._evaluatedInfoLabel = editor.getPaper().text(this.getX(), this.getY(), text).attr(PedigreeEditor.attributes.evaluatedInfoLabel);
							this._evaluatedInfoLabel.alignTop = true;
						} else {
							this._evaluatedInfoLabel = null;
			            }
					}
					
				}
            	
			        
            }
            

            /*
            if(tmp_cancer.length)
			{
				
				lastCancer=tmp_cancer[tmp_cancer.length-1];
                ageType=lastCancer.ageType;
                age=lastCancer.age;
                
			}
			*/
			/*
			if(tmp_cancer.length)
			{
				lastCancer=tmp_cancer[tmp_cancer.length-1];
                ageType=lastCancer.ageType;
                age=lastCancer.age;
			}
			var cancerAgeTypeAbb;
			*/
			//ageType=person.getCancerAgeType();
            /**
			 * edit by GJK
             */
             /*
			if(ageType == "estimatedage") {
				cancerAgeTypeAbb = "(A)"
			} else if(ageType == "exactage") {
				cancerAgeTypeAbb = "(E)"
			} else if(ageType == "none") {
				cancerAgeTypeAbb = "(U)"
			}
			else
                cancerAgeTypeAbb = "";
			if(lastCancer)
			{
                text=lastCancer.name;
                if (age)
                    text += age + "岁"+cancerAgeTypeAbb;
                else if(ageType=="none")
                    text +=cancerAgeTypeAbb;
			}
			else if(person.inactiveHighRelativeCancer() || person.getHighRelativeCancerName() != null) {
				var cancerNameValue = this.getNode().getHighRelativeCancerName();
				if(cancerNameValue == "highcancer_rxa") {
					var cancerName = "乳腺癌";
				} else if(cancerNameValue == "highcancer_lca") {
					var cancerName = "卵巢癌";
				} else if(cancerNameValue == "highcancer_zgnma") {
					var cancerName = "子宫内膜癌";
				} else if(cancerNameValue == "highcancer_jzca") {
					var cancerName = "结直肠癌";
				} else if(cancerNameValue == "highcancer_wa") {
					var cancerName = "胃癌";
				} else if(cancerNameValue == "highcancer_sa") {
					var cancerName = "肾癌";
				} else if(cancerNameValue == "highcancer_qlxa") {
					var cancerName = "前列腺癌";
				} else if(cancerNameValue == "highcancer_jzxa") {
					var cancerName = "甲状腺癌";
				} else if(cancerNameValue == "highcancer_yxa") {
					var cancerName = "胰腺癌";
				} else if(cancerNameValue == "乳腺癌") {
					var cancerName = "乳腺癌";
				} else if(cancerNameValue == "卵巢癌") {
					var cancerName = "卵巢癌";
				} else if(cancerNameValue == "子宫内膜癌") {
					var cancerName = "子宫内膜癌";
				} else if(cancerNameValue == "结直肠癌") {
					var cancerName = "结直肠癌";
				} else if(cancerNameValue == "胃癌") {
                        var cancerName = "胃癌";
				} else if(cancerNameValue == "肾癌") {
                    var cancerName = "肾癌";
                }else if(cancerNameValue == "前列腺癌") {
					var cancerName = "前列腺癌";
				} else if(cancerNameValue == "甲状腺癌") {
					var cancerName = "甲状腺癌";
				} else if(cancerNameValue == "胰腺癌") {
					var cancerName = "胰腺癌";
				}*/
                /**
				 * edit by GJK
                 */
                 /*
                if(cancerName) {
                	text=cancerName;
                    if (age)
                        text += age + "岁"+cancerAgeTypeAbb;
                    else if(ageType=="none")
                    	text +=cancerAgeTypeAbb;
                }
            } else if(person.inactiveUrogenitalTumor() || person.getUrogenitalTumorName() != null) {
				var cancerName = person.getUrogenitalTumorName();
                if(cancerName) {
                    text=cancerName;
                    if (age)
                        text += age + "岁"+cancerAgeTypeAbb;
                    else if(ageType=="none")
                        text +=cancerAgeTypeAbb;
                }
			} else if(person.inactiveGastrointestinalTumor() || person.getGastrointestinalTumorName() != null) {
				var cancerName = person.getGastrointestinalTumorName();
                if(cancerName) {
                    text=cancerName;
                    if (age)
                        text += age + "岁"+cancerAgeTypeAbb;
                    else if(ageType=="none")
                        text +=cancerAgeTypeAbb;
                }
			} else if(person.inactiveOtherTumor() || person.getOtherTumorName() != null) {
				var cancerName = person.getOtherTumorName();
                if(cancerName) {
                    text=cancerName;
                    if (age)
                        text += age + "岁"+cancerAgeTypeAbb;
                    else if(ageType=="none")
                        text +=cancerAgeTypeAbb;
                }
			} else if(person.inactiveRareTumor() || person.getRareTumorName() != null) {
				var cancerName = person.getRareTumorName();
                if(cancerName) {
                    text=cancerName;
                    if (age)
                        text += age + "岁"+cancerAgeTypeAbb;
                    else if(ageType=="none")
                        text +=cancerAgeTypeAbb;
                }
			} else {
				var remaindisorder = this.getNode().getDisorders();
				if(remaindisorder == 0) {
					text = "";
				}
			}*/
			/*
			if(text) {
                this._cancerNameLabel = editor.getPaper().text(this.getX(), this.getY(), text).attr(PedigreeEditor.attributes.label);
                this._cancerNameLabel.alignTop = true;
            }
            */
		} else {
			this._cancerNameLabel = "未患癌";
		}
		this.drawLabels();

	},
	/**
	 * EvaluatedInfoLabel
	 * @method getEvaluatedInfoLabel
	 * @return {Raphael.el}
	 */
	getEvaluatedInfoLabel: function() {
		return this._evaluatedInfoLabel;
	},

	/**
	 *
	 * @method updateCommentsLabel
	 */
	updateEvaluatedInfoLabel: function() {
		this.getEvaluatedInfoLabel() && this.getEvaluatedInfoLabel().remove();
		if(this.getNode().getEvaluatedInfo() != "") {
			var text = this.getNode().getEvaluatedInfo(); //.replace(/\n/g, '<br />');
			this._evaluatedInfoLabel = editor.getPaper().text(this.getX(), this.getY(), text).attr(PedigreeEditor.attributes.evaluatedInfoLabel);
			this._evaluatedInfoLabel.alignTop = true;
		} else {
			this._evaluatedInfoLabel = null;
		}
		//判断癌症
		nametotal = 0;
		var count = 0;
		if (this.getNode.getFirstName) {
			nametotal += 1;
		}
		this.getCancerNameLabel() && this.getCancerNameLabel().remove();
		this.getCancerNameLabel2() && this.getCancerNameLabel2().remove();
		this.getCancerNameLabel3() && this.getCancerNameLabel3().remove();
        this.getCancerNameLabel4() && this.getCancerNameLabel4().remove();
        this.getCancerNameLabel5() && this.getCancerNameLabel5().remove();
		if(this.getNode().getHighRelativeCancerName() != "" || this.getNode().getUrogenitalTumorName() != "" || this.getNode().getGastrointestinalTumorName() != "" || this.getNode().getOtherTumorName() != "" || this.getNode().getRareTumorName() != "") {
			var person = this.getNode();
			var tmp_cancer=person.getCancer();
            ageType=person.getCancerAgeType();
            bPart = person.getSiteOfCancerValue();
            age=person.getCancerAgeNum();
            var lastCancer='';
            var text1 = '';
            var text2 = '';
            var text3 = '';
            var text4 = '';
            var text5 = '';
            //chen.yuguo 显示多个癌症
            if(tmp_cancer.length){
            	//判断是不是有姓名，有则取到前4个，无则取前5个
            	if(this.getNode().getFirstName()){
            		//前四个
            		if(tmp_cancer.length>=4){
            			count = 4;
            		}else{
            			count = tmp_cancer.length;
            		}
            	}else{
            		//前5个
            		if(tmp_cancer.length>=5){
            			count = 5
            		}else{
            			count = tmp_cancer.length;
            		}
            	}
            	for(var i=0;i<count;i++){
            		var text = tmp_cancer[i].name;
            		ageType=tmp_cancer[i].ageType;
                    age=tmp_cancer[i].age;
                    bPart = tmp_cancer[i].bPart;
                    if(ageType == "estimatedage") {
						cancerAgeTypeAbb = "(A)"
					} else if(ageType == "exactage") {
						cancerAgeTypeAbb = "(E)"
					} else if(ageType == "none") {
						cancerAgeTypeAbb = "(U)"
					}
					else
		                cancerAgeTypeAbb = "";
		            
		            if (age){
	                    text += age + "岁"+cancerAgeTypeAbb;
		            }
	                else if(ageType=="none"){
	                    text +=cancerAgeTypeAbb;
	                }
	                if(bPart){
		            	text+=bPart;
					}
	                if(i==0){
			        	text1 = text;
			        }
			        if(i==1){
			        	text2 = text;
			        }
			        if(i==2){
			        	text3 = text;
			        }
			        if(i==3){
			        	text4 = text;
			        }
			        if(i==4){
			        	text5 = text;
			        }
			    }
			    if(text1){
			          	this._cancerNameLabel = editor.getPaper().text(this.getX(), this.getY(), text1).attr(PedigreeEditor.attributes.label);
                        this._cancerNameLabel.alignTop = true;
				}
				if(text2){
				          	this._cancerNameLabel2 = editor.getPaper().text(this.getX(), this.getY(), text2).attr(PedigreeEditor.attributes.label);
	                        this._cancerNameLabel2.alignTop = true;
				}
				if(text3){
				          	this._cancerNameLabel3 = editor.getPaper().text(this.getX(), this.getY(), text3).attr(PedigreeEditor.attributes.label);
	                        this._cancerNameLabel3.alignTop = true;
				}
				if(text4){
				          	this._cancerNameLabel4 = editor.getPaper().text(this.getX(), this.getY(), text4).attr(PedigreeEditor.attributes.label);
	                        this._cancerNameLabel4.alignTop = true;
				}
				if(text5){
				          	this._cancerNameLabel5 = editor.getPaper().text(this.getX(), this.getY(), text5).attr(PedigreeEditor.attributes.label);
	                        this._cancerNameLabel5.alignTop = true;
				}
				if(this.getNode().getFirstName()){
			     	count+=1;
			     }
			     if(count>=5){
					//删除备注和评估
					this.getCommentsLabel() && this.getCommentsLabel().remove();
					this.getEvaluatedInfoLabel() && this.getEvaluatedInfoLabel().remove();
			     }
				if(count<=3){
					//备注
					this.getCommentsLabel() && this.getCommentsLabel().remove();
					if(this.getNode().getComments() != "") {
						var text = this.getNode().getComments(); //.replace(/\n/g, '<br />');
						this._commentsLabel = editor.getPaper().text(this.getX(), this.getY(), text).attr(PedigreeEditor.attributes.commentLabel);
						this._commentsLabel.alignTop = true;
					} else {
						this._commentsLabel = null;
					}
					//评估
					this.getEvaluatedInfoLabel() && this.getEvaluatedInfoLabel().remove();
					if(this.getNode().getEvaluatedInfo() != "") {
						var text = this.getNode().getEvaluatedInfo(); //.replace(/\n/g, '<br />');
						this._evaluatedInfoLabel = editor.getPaper().text(this.getX(), this.getY(), text).attr(PedigreeEditor.attributes.evaluatedInfoLabel);
						this._evaluatedInfoLabel.alignTop = true;
					} else {
						this._evaluatedInfoLabel = null;
		            }
				}
				if(count==4){
					//备注
					if(this.getNode().getComments() != "") {
						this.getEvaluatedInfoLabel() && this.getEvaluatedInfoLabel().remove();
					} else{
						//评估
						this.getEvaluatedInfoLabel() && this.getEvaluatedInfoLabel().remove();
						if(this.getNode().getEvaluatedInfo() != "") {
							var text = this.getNode().getEvaluatedInfo(); //.replace(/\n/g, '<br />');
							this._evaluatedInfoLabel = editor.getPaper().text(this.getX(), this.getY(), text).attr(PedigreeEditor.attributes.evaluatedInfoLabel);
							this._evaluatedInfoLabel.alignTop = true;
						} else {
							this._evaluatedInfoLabel = null;
			            }
					}
					
				}
            	
			        
            }
		} else {
			this._cancerNameLabel = "未患癌";
		}
		this.drawLabels();
	},
	/**
	 *
	 * @method updateLifeStatusShapes
	 */
	updateLifeStatusShapes: function(oldStatus) {
		var status = this.getNode().getLifeStatus();

		this.getDeadShape() && this.getDeadShape().remove();
		this.getUnbornShape() && this.getUnbornShape().remove();
		this.getSBLabel() && this.getSBLabel().remove();

		var oldShapeType = (oldStatus == 'aborted' || oldStatus == 'miscarriage');
		var newShapeType = (status == 'aborted' || status == 'miscarriage');
		if(oldShapeType != newShapeType)
			this.setGenderGraphics();

		if(status == 'deceased' || status == 'aborted') {
			this.drawDeadShape();
		} else if(status == 'stillborn') {
			this.drawDeadShape();
			this.updateSBLabel();
		} else if(status == 'unborn') {
			this.drawUnbornShape();
		}
		//this.updateAgeLabel();
	},

	/**
	 *
	 * @method setSelected
	 */
	setSelected: function($super, isSelected) {
		$super(isSelected);
		if(isSelected) {
			this.shiftLabels();
		} else {
			this.unshiftLabels();
		}
	},

	/**
	 *
	 * @method shiftLabels
	 */
	shiftLabels: function() {
		var shift = this._labelSelectionOffset();
		var labels = this.getLabels();
		for(var i = 0; i < labels.length; i++) {
			labels[i].stop().animate({
				"y": labels[i].oy + shift
			}, 200, ">");
		}
	},

	/**
	 *
	 * @method unshiftLabels
	 */
	unshiftLabels: function() {
		var labels = this.getLabels();
		var firstLable = this._childlessStatusLabel ? 1 : 0;
		for(var i = 0; i < labels.length; i++) {
			labels[i].stop().animate({
				"y": labels[i].oy
			}, 200, ">");
		}
	},

	/**
	 * @method getLabels
	 * @return {Raphael.st}
	 */
	getLabels: function() {
		var labels = editor.getPaper().set();
		this.getSBLabel() && labels.push(this.getSBLabel());
		this.getNameLabel() && labels.push(this.getNameLabel());
		this.getAgeLabel() && labels.push(this.getAgeLabel());
		this.getExternalIDLabel() && labels.push(this.getExternalIDLabel());
		this.getCancerNameLabel() && labels.push(this.getCancerNameLabel());
		this.getCancerNameLabel2() && labels.push(this.getCancerNameLabel2());
		this.getCancerNameLabel3() && labels.push(this.getCancerNameLabel3());
		this.getCancerNameLabel4() && labels.push(this.getCancerNameLabel4());
		this.getCancerNameLabel5() && labels.push(this.getCancerNameLabel5());
		this.getEvaluatedInfoLabel() && labels.push(this.getEvaluatedInfoLabel());
		this.getCommentsLabel() && labels.push(this.getCommentsLabel());
		this.getProbabilityLabel() && labels.push(this.getProbabilityLabel());
		return labels;
	},
	setAnonymizedStatus: function($super, status) {
		$super(status);
		this.drawLabels();
	},
	/**
	 * @method drawLabels
	 */
	drawLabels: function() {
		/*
		var nowtotal = 0;
		if(this.getNameLabel()){
			nowtotal += 1;
		}
		if(this.getCancerNameLabel()){
			nowtotal +=1;
		}
		if(this.getCancerNameLabel2()){
			nowtotal +=1;
		}
		if(this.getCancerNameLabel3()){
			nowtotal += 1;
		}
		if(this.getCancerNameLabel4()){
			nowtotal += 1;
		}
		if(nowtotal>=5){
			this.getCancerNameLabel5() && this.getCancerNameLabel5().remove();
		}else{
			if(this.getCancerNameLabel5()){
			   nowtotal += 1;
		    }
		    if(nowtotal>=5){
				this.getCommentsLabel() && this.getCommentsLabel().remove();
				//this.getNode().getEvaluated()&&this.getNode().getEvaluated().remove();
			}else{
				if(this.getCommentsLabel()){
					nowtotal +=1;
				}
				if (nowtotal>=5) {
					//this.getNode().getEvaluated()&&this.getNode().getEvaluated().remove();
				}
			}
		}*/
		var labels = this.getLabels();
		var selectionOffset = this._labelSelectionOffset();
		var childlessOffset = this.getChildlessStatusLabel() ? PedigreeEditor.attributes.label['font-size'] : 0;
		childlessOffset += ((this.getNode().getChildlessStatus() !== null) ? (PedigreeEditor.attributes.infertileMarkerHeight + 2) : 0);
		var lowerBound = PedigreeEditor.attributes.radius * (this.getNode().isPersonGroup() ? PedigreeEditor.attributes.groupNodesScale : 1.0);
		var startY = this.getY() + lowerBound * 1.8 + selectionOffset + childlessOffset;
		console.log(labels)
		for(var i = 0; i < labels.length; i++) {
			text=labels[i].attrs.text;
            var offset = (labels[i].alignTop) ? (getElementHalfHeight(labels[i]) - 7) : 0;
			labels[i].attr("y", startY+offset);
			labels[i].oy = (labels[i].attr("y") - selectionOffset);
			startY = labels[i].getBBox().y2 + 11;
			console.log(labels[i],getElementHalfHeight(labels[i]),startY,text);
		}
		if(!editor.isUnsupportedBrowser())
			labels.flatten().insertBefore(this.getHoverBox().getFrontElements().flatten());
	},

	_labelSelectionOffset: function() {
		var selectionOffset = this.isSelected() ? PedigreeEditor.attributes.radius / 1.4 : 0;

		if(this.isSelected() && this.getNode().isPersonGroup())
			selectionOffset += PedigreeEditor.attributes.radius * (1 - PedigreeEditor.attributes.groupNodesScale) + 5;

		if(this.getChildlessStatusLabel())
			selectionOffset = selectionOffset / 2;
		return selectionOffset;
	},

	/**
	 *
	 * @method getShapes
	 * @return {Raphael.st}
	 */
	getShapes: function($super) {
		var lifeStatusShapes = editor.getPaper().set();
		this.getUnbornShape() && lifeStatusShapes.push(this.getUnbornShape());
		this.getChildlessShape() && lifeStatusShapes.push(this.getChildlessShape());
		this.getChildlessStatusLabel() && lifeStatusShapes.push(this.getChildlessStatusLabel());
		this.getDeadShape() && lifeStatusShapes.push(this.getDeadShape());
		return $super().concat(editor.getPaper().set(this.getDisorderShapes(), lifeStatusShapes));
	},

	/**
	 *
	 * @method getAllGraphics
	 * @return {Raphael.st}
	 */
	getAllGraphics: function($super) {
		//console.log("Node " + this.getNode().getID() + " getAllGraphics");
		return $super().push(this.getHoverBox().getBackElements(), this.getLabels(), this.getCarrierGraphics(), this.getEvaluationGraphics(), this.getHoverBox().getFrontElements());
	},

	/**
	 *
	 * @method setPos
	 * @param [$super]
	 * @param {Number} x 
	 * @param {Number} y 
	 * @param {Boolean} animate 
	 * @param {Function} callback 
	 */
	setPos: function($super, x, y, animate, callback) {
		var funct = callback;
		if(animate) {
			var me = this;
			this.getHoverBox().disable();
			funct = function() {
				me.getHoverBox().enable();
				callback && callback();
			};
		}
		$super(x, y, animate, funct);
	}
});

PersonVisuals.addMethods(ChildlessBehaviorVisuals);